package com.example.capsule_netty.mapper;

import com.example.capsule_netty.bean.UserInfoBean;
import com.example.capsule_netty.bean.UserToImeiBean;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


/**
 * @Author: zhuzhiming
 * @Date: 2022/4/28 12:05
 */
public interface UserToImeiBeanMapper extends JpaRepository<UserToImeiBean, Integer> {

    @Query(value = "select * from user_to_imei where user_to_imei.imei = ?1", nativeQuery = true)
    List<UserToImeiBean> getUserByMesi(String imei);

    @Query(value = "select max(id + 0) from user_to_imei", nativeQuery = true)
    int getMaxId();

    @Query(value = "select user_id from user_to_imei where imei = ?1", nativeQuery = true)
    String getUserIdByImei(String imei);

    @Query(value = "select  imei from user_to_imei where user_id = ?1", nativeQuery = true)
    String getImeiByUserId(String userId);

    @Query(value = "select * from user_to_imei limit 1", nativeQuery = true)
    UserToImeiBean judgeHasOne();

    @Query(value = "truncate table user_to_imei", nativeQuery = true)
    void doTruncateTable();
}
